package com.junzhiit.nengji.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.bainaeco.framework.base.dao.AbstractBaseDAO;
import com.bainaeco.framework.common.jdbc.StatementParameter;
import com.bainaeco.framework.enums.IsDelete;
import com.junzhiit.nengji.dao.BankCardDAO;
import com.junzhiit.nengji.model.BankCard;

@Repository
public class BankCardDAOImpl extends AbstractBaseDAO<BankCard> implements BankCardDAO{

	@Override
	public List<BankCard> findAll(String shopId) {
		StringBuffer sql = new StringBuffer();
		sql.append("select * from bank_card where shop_id = ? AND is_delete = ?");

		StatementParameter param = new StatementParameter();
		param.setString(shopId);
		param.setInt(IsDelete.NO.toIntValue());

		return queryForList(sql.toString(), BankCard.class, param);
	}

	@Override
	public BankCard findByCardNumber(String shopId,String number) {
		StringBuffer sql = new StringBuffer();
		sql.append("select * from bank_card where shop_id = ? AND bank_card = ? AND is_delete = ?");

		StatementParameter param = new StatementParameter();
		param.setString(shopId);
		param.setString(number);
		param.setInt(IsDelete.NO.toIntValue());

		return query(sql.toString(), BankCard.class, param);
	}

	@Override
	public List<String> findShopId() {
		StringBuffer sql = new StringBuffer();
		sql.append("select id from shop where is_delete = ?");

		StatementParameter param = new StatementParameter();
		param.setInt(IsDelete.NO.toIntValue());

		return queryForStrings(sql.toString(),  param);
	}

	@Override
	public List<String> fingUserId() {
		StringBuffer sql = new StringBuffer();
		sql.append("select id from user where is_delete = ?");

		StatementParameter param = new StatementParameter();
		param.setInt(IsDelete.NO.toIntValue());
		
		return queryForStrings(sql.toString(),  param);
	}

	
}
